#pragma once

#include <windows.h>

class FileHolder
{
public:
	FileHolder();
	~FileHolder();

	bool	openToRead(const char *filename);
	bool	openToWrite(const char *filename);
	bool	openToReadWrite(const char *filename);
	bool	create(const char *filename);
	void	seek(DWORD pos);
	DWORD	getFileSize();
	void	close();

	static bool	isFileExisting(const char *filename);

	void	writeBuffer(BYTE *data, DWORD amount);
	void	writeByte(BYTE data);
	void	writeWord(WORD data);
	void	writeDword(DWORD data);
	void	writeInt(int data);
	void	writeFloat(float data);
	void	writeText(char *text);

	void	readBuffer(BYTE *data, DWORD amount);
	BYTE	readByte();
	WORD	readWord();
	DWORD	readDword();
	int		readInt();
	float	readFloat();

private:
	HANDLE	hfile;

	bool	checkError();
};